package com.cxyjy.travelguide.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cxyjy.common.core.mapper.BaseMapperX;
import com.cxyjy.common.pojo.PageResult;
import com.cxyjy.common.util.JObjectUtil;
import com.cxyjy.travelguide.controller.vo.ArtifactQueryVO;
import com.cxyjy.travelguide.controller.vo.ArtifactRespVO;
import com.cxyjy.travelguide.dal.dataobject.ExternalArtifactDO;
import com.cxyjy.travelguide.dal.dataobject.ExternalBaiduAiImageDO;
import com.cxyjy.travelguide.entity.ExternalArtifact;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;

/**
* @author jonyl
* @description 针对表【external_artifact(文物基础信息表)】的数据库操作Mapper
* @createDate 2025-05-13 14:16:35
* @Entity com.cxyjy.jproject.entity.ExternalArtifact
*/
@Mapper
public interface ExternalArtifactMapper extends BaseMapperX<ExternalArtifactDO> {

    default PageResult<ArtifactRespVO> selectPage(ArtifactQueryVO queryVO) {

//        return selectPage(queryVO,
//                new LambdaQueryWrapper<ExternalArtifactDO>()
//                .like(JObjectUtil.isNotEmpty(queryVO.getCode()), ExternalArtifactDO::getCode, queryVO.getCode()));
        return selectJoinPage(queryVO,ArtifactRespVO.class,new MPJLambdaWrapper<ExternalArtifactDO>()
                .selectAll(ExternalArtifactDO.class)
                .leftJoin(ExternalBaiduAiImageDO.class,ExternalBaiduAiImageDO::getCode,ExternalArtifactDO::getCode)
                .disableSubLogicDel()
                .select(ExternalBaiduAiImageDO::getClassId1,ExternalBaiduAiImageDO::getClassId2)
                .groupBy(ExternalArtifactDO::getId)
                .orderByDesc(ExternalArtifactDO::getId)
        );
    }

    int deleteByPrimaryKey(Long id);

    int deleteByCode(String code);

    int insert(ExternalArtifact record);

    int insertSelective(ExternalArtifact record);

    ExternalArtifact selectByPrimaryKey(Long id);

    ExternalArtifact selectByCode(String code);

    int updateByPrimaryKeySelective(ExternalArtifact record);

    int updateByPrimaryKey(ExternalArtifact record);

}
